﻿using Dapper.DBContext.Schema;
using Guoc.BigMall.Domain.Entity;
using Guoc.BigMall.Domain.ValueObject;
using Guoc.BigMall.Infrastructure.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Guoc.BigMall.Application.ViewObject
{
   public class SaleOrderVo
    {
        public SaleOrderVo() {
            Items = new List<SaleOrderItemVo>();
        }

        public int Id { get; set; }

        /// <summary>
        /// 订单编号 ： 单据类型 2 + 账号4位+ （日期20160101） 3位+ 下单的秒数（86400，5位）+ 2位随机
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 门店
        /// </summary>
        public int StoreId { get; set; }

        /// <summary>
        /// 订单类型：销售单1，销售退单2
        /// </summary>
        public int OrderType { get; set; }
        /// <summary>
        /// 支付方式
        /// </summary>
        public PaymentWay? PaymentWay { get; set; }

        /// <summary>
        ///  付款状态
        /// </summary>
        public OrderPayStatus PayStatus { get; set; }
        public string PayStatusName { get { return this.PayStatus.Description(); } }
        /// <summary>
        /// 支付日期
        /// </summary>
        public DateTime? PaidDate { get; set; }
        public string PaidDateTime
        {
            get
            {
                return this.PaidDate.HasValue ? this.PaidDate.Value.ToString("yyyy-MM-dd") : string.Empty;
            }
        }

        public int Hour { get; set; }

        /// <summary>
        /// 订单金额 = 实际价格RealAmount * 数量
        /// </summary> 
        public decimal OrderAmount { get; set; }
        /// <summary>
        /// 销售单状态
        /// </summary>
        public SaleOrderStatus Status { get; set; }

        public string StatusName
        {
            get
            {
                return Status.Description();
            }
        }

        public DateTime? CreatedOn { get; set; }
        public string CreatedOnTime
        {
            get
            {
                return CreatedOn.HasValue ? CreatedOn.Value.ToString("yyyy-MM-dd") : string.Empty;
            }
        }

        /// <summary>
        ///  下单客户
        /// </summary>
        public int CustomerId { get; set; }

        /// <summary>
        ///  推会员ID
        /// </summary>
        public int ReferMemberId { get; set; }

        public int UpdatedBy { get; set; }

        public DateTime UpdatedOn { get; set; }

        public string AreaId { get; set; }
        public string ReceiverAreaFullName { get; set; }
        public string ReceiverAddress { get; set; }

        /// <summary>
        /// 收货人全地址
        /// </summary>
        public string ReceiverFullAddress
        {
            get
            {
                return this.ReceiverAreaFullName + ReceiverAddress;
            }
        }
        public string ReceiverTel { get; set; }
        public string ReceiverName { get; set; }

        public IEnumerable<SaleOrderItemVo> Items { get; set; }
    }
}
